package com.whut.monitor.util;

import org.apache.commons.lang.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

import static com.whut.monitor.util.ProtocolUtil.FGBtoSSTSFTMap;

/**
 * @author Sandeepin
 * 2017/3/30
 * Hbase相关处理函数
 */
public class HbaseUtil {

    /**
     * 收到的包转为Hbase存储优化的形式
     * @param msg 数据协议包
     * @param map 映射为Hbase的键值对
     * @return 时间
     */
    public static String package2HbaseMap(String msg, Map<String, String> map) {
        String[] arr = msg.split("\n");
        // 包日期-自然形式 2017-03-30 12:13:14
        String strDate = null;
        // 包日期-压缩形式 170330121314
        String dateMin = null;
        // 机床编号-自然形式 001
        String devNum = null;
        // 机床编号-编码形式 0-Z两位
        String devNumEn = null;
        // 传感器唯一编号
        String name = null;
        // 临时值
        String value;

        // 每类数据存值
        StringBuilder builderSDT = new StringBuilder();
        StringBuilder builderSFT = new StringBuilder();
        StringBuilder builderSST = new StringBuilder();
        StringBuilder builderSCD = new StringBuilder();
        StringBuilder builderSET = new StringBuilder();
        StringBuilder builderSCN = new StringBuilder();

        // 判断每类数据是否存在
        boolean haveSDT = false;
        boolean haveSFT = false;
        boolean haveSST = false;
        boolean haveSCD = false;
        boolean haveSCN = false;
        boolean haveSET = false;

        // 电类数据集合
        Map<String, String> ds18b20Map = new TreeMap<>();
        ds18b20Map.put("001-SDT00-00", "0");
        ds18b20Map.put("001-SDT00-01", "0");
        ds18b20Map.put("001-SDT00-02", "0");
        ds18b20Map.put("001-SDT00-03", "0");
        ds18b20Map.put("001-SDT00-04", "0");
        ds18b20Map.put("001-SDT00-05", "0");
        ds18b20Map.put("001-SDT00-06", "0");
        ds18b20Map.put("001-SDT00-07", "0");
        ds18b20Map.put("001-SDT01-00", "0");
        ds18b20Map.put("001-SDT01-01", "0");
        ds18b20Map.put("001-SDT01-02", "0");
        ds18b20Map.put("001-SDT01-03", "0");
        ds18b20Map.put("001-SDT01-04", "0");
        ds18b20Map.put("001-SDT01-05", "0");
        ds18b20Map.put("001-SDT01-06", "0");
        ds18b20Map.put("001-SDT01-07", "0");
        ds18b20Map.put("001-SDT02-00", "0");
        ds18b20Map.put("001-SDT02-01", "0");
        ds18b20Map.put("001-SDT02-02", "0");
        ds18b20Map.put("001-SDT02-03", "0");
        ds18b20Map.put("001-SDT02-04", "0");
        ds18b20Map.put("001-SDT02-05", "0");
        ds18b20Map.put("001-SDT02-06", "0");
        ds18b20Map.put("001-SDT02-07", "0");
        ds18b20Map.put("001-SDT03-00", "0");
        ds18b20Map.put("001-SDT03-01", "0");
        ds18b20Map.put("001-SDT03-02", "0");
        ds18b20Map.put("001-SDT03-03", "0");
        ds18b20Map.put("001-SDT03-04", "0");
        ds18b20Map.put("001-SDT03-05", "0");
        ds18b20Map.put("001-SDT03-06", "0");
        ds18b20Map.put("001-SDT03-07", "0");
        ds18b20Map.put("001-SDT04-00", "0");
        ds18b20Map.put("001-SDT04-01", "0");
        ds18b20Map.put("001-SDT04-02", "0");
        ds18b20Map.put("001-SDT04-03", "0");
        ds18b20Map.put("001-SDT04-04", "0");
        ds18b20Map.put("001-SDT04-05", "0");
        ds18b20Map.put("001-SDT04-06", "0");
        ds18b20Map.put("001-SDT04-07", "0");
        ds18b20Map.put("001-SDT05-00", "0");
        ds18b20Map.put("001-SDT05-01", "0");
        ds18b20Map.put("001-SDT05-02", "0");
        ds18b20Map.put("001-SDT05-03", "0");
        ds18b20Map.put("001-SDT05-04", "0");
        ds18b20Map.put("001-SDT05-05", "0");
        ds18b20Map.put("001-SDT05-06", "0");
        ds18b20Map.put("001-SDT05-07", "0");
        ds18b20Map.put("001-SDT06-00", "0");
        ds18b20Map.put("001-SDT06-01", "0");
        ds18b20Map.put("001-SDT06-02", "0");
        ds18b20Map.put("001-SDT06-03", "0");
        ds18b20Map.put("001-SDT06-04", "0");
        ds18b20Map.put("001-SDT06-05", "0");
        ds18b20Map.put("001-SDT06-06", "0");
        ds18b20Map.put("001-SDT06-07", "0");
        ds18b20Map.put("001-SDT07-00", "0");
        ds18b20Map.put("001-SDT07-01", "0");
        ds18b20Map.put("001-SDT07-02", "0");
        ds18b20Map.put("001-SDT07-03", "0");
        ds18b20Map.put("001-SDT07-04", "0");
        ds18b20Map.put("001-SDT07-05", "0");
        ds18b20Map.put("001-SDT07-06", "0");
        ds18b20Map.put("001-SDT07-07", "0");

        // 环境温度合集
        Map<String, String> envMap = new TreeMap<>();
        envMap.put("001-SET00-00", "0");
        envMap.put("001-SET00-01", "0");
        envMap.put("001-SET01-00", "0");
        envMap.put("001-SET01-01", "0");

        // CNC数据有序Map
        Map<String, String> cncDataOrderMap = new HashMap<>();

        for (String str : arr) {
            // 时间
            if (str.startsWith("@@")) {
                String[] tempdate = str.split(",", -1);
                strDate = tempdate[1];
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                SimpleDateFormat sdf2 = new SimpleDateFormat("yyMMddHHmmss");
                try {
                    java.util.Date date = sdf1.parse(strDate);
                    dateMin = sdf2.format(date);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                //System.out.println("[时间]"+strDate +"[时间精简]"+Date);
            }
            // 机床编号
            if (str.startsWith("SDV")) {
                String[] tempdev = str.split(",", -1);
                devNum = tempdev[1] + "-";
                devNumEn = tempdev[1].substring(1, 3).trim();
                //System.out.println("[编号]"+devNum +"[编号编码]"+devNumEn);
            }
            // 电类温度数据
            if (str.startsWith("SDT")) {
                haveSDT = true;
                String[] tempstr = str.split(",", -1);
                String monitorNum = ProtocolUtil.ds18b20id2monitorNum(tempstr[2]);
                value = tempstr[3];
                if (null != monitorNum) {
                    ds18b20Map.put(monitorNum, value);
                }
                //System.out.println("[唯一编号]"+monitorNum+" [值]"+value);
            }
            // 环境温度数据
            if (str.startsWith("SET")) {
                haveSET = true;
                String[] tempstr = str.split(",", -1);
                String monitorNum = ProtocolUtil.envid2monitorNum(tempstr[2]);
                value = tempstr[3];
                if (null != monitorNum) {
                    envMap.put(monitorNum, value);
                }
            }
            // FBG 温度数据
            if (str.startsWith("SFT")) {
                haveSFT = true;
                String[] tempstr = str.split(",", -1);
                String monitorNum = devNum + tempstr[0] + "-" + tempstr[1];
                if ("".equals(tempstr[2]) || "0000.000".equals(tempstr[2])) {
                    value = "0";
                } else {
                    value = tempstr[2];
                }
                builderSFT.append(value).append(",");
                //System.out.println("[唯一编号]"+monitorNum+" [值]"+value);
            }
            // FBG 应力数据
            if (str.startsWith("SST")) {
                haveSST = true;
                String[] tempstr = str.split(",", -1);
                String monitorNum = devNum + tempstr[0] + "-" + tempstr[1];
                if ("".equals(tempstr[2]) || "0000.000".equals(tempstr[2])) {
                    value = "0";
                } else {
                    value = tempstr[2];
                }
                builderSST.append(value).append(",");
                //System.out.println("[唯一编号]"+monitorNum+" [值]"+value);
            }
            // CCD位移
            if (str.startsWith("SCD")) {
                haveSCD = true;
                String[] tempstr = str.split(",", -1);
                for (int i = 0; i < 3; i++) {
                    if ("X".equals(tempstr[2 * i + 1])) {
                        name = "00";
                    }
                    if ("Y".equals(tempstr[2 * i + 1])) {
                        name = "01";
                    }
                    if ("Z".equals(tempstr[2 * i + 1])) {
                        name = "02";
                    }
                    String monitorNum = devNum + tempstr[0] + "-" + name;
                    if ("".equals(tempstr[2 * i + 2])) {
                        value = "0";
                    } else {
                        value = tempstr[2 * i + 2];
                    }
                    builderSCD.append(value).append(",");
                    //System.out.println("[唯一编号]"+monitorNum+" [值]"+value);
                }
            }
            // 机床本体数据
            if (str.startsWith("SCN")) {
                haveSCN = true;
                String[] tempstr = str.split(",", -1);
                // 获取XYZ主轴坐标
                if ("CH".equals(tempstr[1])) {
                    // 放入CH值0
                    cncDataOrderMap.put("CH", tempstr[2]);
                    for (int i = 1; i < 5; i++) {
                        if ("XPOS".equals(tempstr[2 * i + 1])) {
                            name = "XPOS";
                        }
                        if ("YPOS".equals(tempstr[2 * i + 1])) {
                            name = "YPOS";
                        }
                        if ("ZPOS".equals(tempstr[2 * i + 1])) {
                            name = "ZPOS";
                        }
                        if ("MAPOS".equals(tempstr[2 * i + 1])) {
                            name = "MAPOS";
                        }
                        if ("".equals(tempstr[2 * i + 2])) {
                            value = "0";
                        } else {
                            value = tempstr[2 * i + 2];
                        }
                        cncDataOrderMap.put(name, value);
                        //System.out.println("[唯一编号]"+monitorNum+" [值]"+value);
                    }
                }
                // 获取XYZ主轴功率-数值
                if ("XPWR".equals(tempstr[1])) {
                    for (int i = 0; i < 4; i++) {
                        if ("XPWR".equals(tempstr[2 * i + 1])) {
                            name = "XPWR";
                        }
                        if ("YPWR".equals(tempstr[2 * i + 1])) {
                            name = "YPWR";
                        }
                        if ("ZPWR".equals(tempstr[2 * i + 1])) {
                            name = "ZPWR";
                        }
                        if ("MAPWR".equals(tempstr[2 * i + 1])) {
                            name = "MAPWR";
                        }
                        if ("".equals(tempstr[2 * i + 2])) {
                            value = "0";
                        } else {
                            value = tempstr[2 * i + 2];
                        }
                        cncDataOrderMap.put(name, value);
                        //System.out.println("[唯一编号]"+monitorNum+" [值]"+value);
                    }
                }
                // 获取XYZ主轴功率-百分比
                if ("XFU".equals(tempstr[1])) {
                    for (int i = 0; i < 4; i++) {
                        if ("XFU".equals(tempstr[2 * i + 1])) {
                            name = "XFU";
                        }
                        if ("YFU".equals(tempstr[2 * i + 1])) {
                            name = "YFU";
                        }
                        if ("ZFU".equals(tempstr[2 * i + 1])) {
                            name = "ZFU";
                        }
                        if ("MAFU".equals(tempstr[2 * i + 1])) {
                            name = "MAFU";
                        }
                        if ("".equals(tempstr[2 * i + 2])) {
                            value = "0";
                        } else {
                            value = tempstr[2 * i + 2];
                        }
                        cncDataOrderMap.put(name, value);
                        //System.out.println("[唯一编号]"+monitorNum+" [值]"+value);
                    }
                }
                // 获取进给速率\主轴转速\机床状态
                if ("FR".equals(tempstr[1])) {
                    for (int i = 0; i < 3; i++) {
                        if ("FR".equals(tempstr[2 * i + 1])) {
                            name = "FR";
                        }
                        if ("SP".equals(tempstr[2 * i + 1])) {
                            name = "SP";
                        }
                        if ("PA".equals(tempstr[2 * i + 1])) {
                            name = "PA";
                        }
                        String monitorNum = devNum + name;
                        if ("".equals(tempstr[2 * i + 2])) {
                            value = "0";
                        } else {
                            value = tempstr[2 * i + 2];
                        }
                        cncDataOrderMap.put(name, value);
                        //System.out.println("[唯一编号]"+monitorNum+" [值]"+value);
                    }
                }
                // 获取机床报警号
                if ("ERR".equals(tempstr[1])) {
                    name="ERR";
                    String monitorNum = devNum + name;
                    if ("".equals(tempstr[5])) {
                        value = "0";
                    } else {
                        value = tempstr[5];
                    }
                    cncDataOrderMap.put(name, value);
//                    builderSCN.append(value).append(",");
                }
            }
        }

        // 电类单独处理
        for (String e:ds18b20Map.keySet())
        {
            builderSDT.append(ds18b20Map.get(e)).append(",");
        }
        // 环境温度单独处理
        for (String e:envMap.keySet())
        {
            builderSET.append(envMap.get(e)).append(",");
        }
        // CNC数据按顺序处理
        builderSCN.append(cncDataOrderMap.get("CH")).append(",");
        builderSCN.append(cncDataOrderMap.get("XPOS")).append(",");
        builderSCN.append(cncDataOrderMap.get("YPOS")).append(",");
        builderSCN.append(cncDataOrderMap.get("ZPOS")).append(",");
        builderSCN.append(cncDataOrderMap.get("MAPOS")).append(",");
        builderSCN.append(cncDataOrderMap.get("FR")).append(",");
        builderSCN.append(cncDataOrderMap.get("SP")).append(",");
        builderSCN.append(cncDataOrderMap.get("XPWR")).append(",");
        builderSCN.append(cncDataOrderMap.get("YPWR")).append(",");
        builderSCN.append(cncDataOrderMap.get("ZPWR")).append(",");
        builderSCN.append(cncDataOrderMap.get("MAPWR")).append(",");
        builderSCN.append(cncDataOrderMap.get("XFU")).append(",");
        builderSCN.append(cncDataOrderMap.get("YFU")).append(",");
        builderSCN.append(cncDataOrderMap.get("ZFU")).append(",");
        builderSCN.append(cncDataOrderMap.get("MAFU")).append(",");
        builderSCN.append(cncDataOrderMap.get("PA")).append(",");

        String strSDT = new String(builderSDT);
        String strSFT = new String(builderSFT);
        String strSST = new String(builderSST);
        String strSCD = new String(builderSCD);
        String strSCN = new String(builderSCN);
        String strSET = new String(builderSET);

        if(haveSDT) {map.put(devNumEn + "DT" + dateMin, strSDT);}
        if(haveSFT) {map.put(devNumEn + "FT" + dateMin, strSFT);}
        if(haveSST) {map.put(devNumEn + "ST" + dateMin, strSST);}
        if(haveSCD) {map.put(devNumEn + "CD" + dateMin, strSCD);}
        if(haveSCN) {map.put(devNumEn + "CN" + dateMin, strSCN);}
        if(haveSET) {map.put(devNumEn + "ET" + dateMin, strSET);}

        return strDate;
    }

    // 抽样取点函数
    public static List<Integer> sampling(int nowNum, int needNum)
    {
        List<Integer> outList = new LinkedList<>();;
        // 压缩
        if (nowNum >= needNum)
        {
            double bilv = needNum*1.0 / nowNum;
		    int[] data = new int[nowNum];
            for (int i = 0; i < nowNum; ++i)
            {
                data[i] = (int) Math.floor(i*bilv);
            }

            int value = -1;
            for (int i = 0; i < nowNum; ++i)
            {
                if (data[i] != value)
                {
                    outList.add(i);
                    value = data[i];
                }
            }
        }
        // 拉伸
        if (nowNum < needNum)
        {
            double bilv = nowNum*1.0 / needNum;
            int[] data = new int[needNum];
            for (int i = 0; i < needNum; ++i)
            {
                data[i] = (int) Math.floor(i*bilv);
                outList.add(data[i]);
            }
        }
        return outList;
    }

    /**
     * 数据抽样算法, 需要优化(sandeepin 2017-4-7)
     * @param samplePoint       抽样的点数
     * @param dateArray         时间数组
     * @param valuesArray       值多维数组
     * @param sampleDateArray   抽样的时间数组
     * @return 抽样后的数组
     */
    public static String[][] samplinArithmetic(int samplePoint, String[] dateArray, String[][] valuesArray, String[] sampleDateArray)
    {
        if (dateArray.length > 0 && valuesArray.length >0){
            List<Integer> list = sampling(dateArray.length, samplePoint);
            // 数据抽样
            String[][] sampleValueArray = new String[valuesArray.length][samplePoint];
            for(int i=0; i < valuesArray.length; i++) {
                for(int j=0; j < samplePoint; j++) {
                    sampleValueArray[i][j] = valuesArray[i][list.get(j)];
                }
            }
            // 时间抽样
            for(int j=0; j < samplePoint; j++) {
                sampleDateArray[j] = dateArray[list.get(j)];
            }
            return sampleValueArray;
        }
        // 返回空
        String[][] sampleValueArray = new String[valuesArray.length][dateArray.length];
        return sampleValueArray;
    }

    /**
     * 由收到的时间+ID编号，转为Hbase中RowKey形式，例如2017-03-31 12:13:114 001-SDT00-00 转为devNumEn:01  sensorType:DT  Date:170331121314
     * @param date 日期
     * @param idArray 传感器编号
     * @return 转换后的形式，可在map中取
     */
    public static Map<String, String> webData2HbaseRowkey(String date, String idArray)
    {
        // 对id数组进行切片, 每个单独处理
        String[] idArr = idArray.split(",");
        // 对第一个id进行处理, 同时得到数组二维信息
        String[] arr = idArr[0].split("-");
        // 提取 Hbase RowKey 中需要的信息
        // 设备号
        String devNumEn =arr[0].substring(1,3).trim();
        // 传感器类型
        String sensorType;
        // 传感器前2个字符，用于找出机床内部信息
        String arrQian2 =arr[1].substring(0,2).trim();
        if (
                "X".equals(arrQian2.substring(0, 1)) ||
                "Y".equals(arrQian2.substring(0, 1)) ||
                "Z".equals(arrQian2.substring(0, 1)) ||
                "M".equals(arrQian2.substring(0, 1)) ||
                "F".equals(arrQian2.substring(0, 1)) ||
                "P".equals(arrQian2.substring(0, 1)) ||
                "SP".equals(arrQian2.substring(0, 2)))
        {
            System.out.println("机床内部信息");
            sensorType = "CN";
        }
        else {
            // 传感器类型
            sensorType =arr[1].substring(1,3).trim();
        }

        // 日期
        String dateMin = "";
        SimpleDateFormat sdf1 = new SimpleDateFormat( "yyyy-MM-dd" );
        SimpleDateFormat sdf2 = new SimpleDateFormat( "yyMMdd" );
        try
        {
            java.util.Date datestand = sdf1.parse(date);
            dateMin = sdf2.format(datestand);
        }
        catch (ParseException e)
        {
            e.printStackTrace();
        }
        Map<String,String> outMap= new HashMap<>();
        outMap.put("devNumEn",devNumEn);
        outMap.put("sensorType",sensorType);
        outMap.put("Date",dateMin);

        return outMap;
    }

    /**
     * HbaseTime中的time形式转标准的时间格式
     * @param hbaseTime 例 170407121314
     * @return 例 2017-04-07 12:13:14
     */
    public static String hbaseTime2StandardTime(String hbaseTime)
    {
        String time =  "20" + hbaseTime;
        SimpleDateFormat sdf3 = new SimpleDateFormat( "yyyyMMddHHmmss" );
        // HH大写为24小时制
        //SimpleDateFormat sdf4 = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
        // 只显示 小时 和 分钟
        SimpleDateFormat sdf4 = new SimpleDateFormat( "HH:mm" );
        try
        {
            java.util.Date timestand = sdf3.parse(time);
            time = sdf4.format(timestand);
        }
        catch (ParseException e)
        {
            e.printStackTrace();
        }
        return time;
    }

    public static String hbaseTime2StandardTime(String hbaseTime, String pattern)
    {
        String time =  "20" + hbaseTime;
        SimpleDateFormat sdf3 = new SimpleDateFormat( "yyyyMMddHHmmss" );
        // HH大写为24小时制
        //SimpleDateFormat sdf4 = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
        // 只显示 小时 和 分钟
        SimpleDateFormat sdf4 = new SimpleDateFormat( pattern);
        try
        {
            java.util.Date timestand = sdf3.parse(time);
            time = sdf4.format(timestand);
        }
        catch (ParseException e)
        {
            e.printStackTrace();
        }
        return time;
    }

    /**
     * 由HbaseValue解析出对应传感器值
     * @param map 从Hbase中获取的原生数据map（map的键没用到，只用了值）
     * @param idArray 要获取的传感器编号数组
     * @param sensorType 传感器类型
     * @return 指定的传感器的数据数组
     */
    public static String[][] hbaseValue2OneValue(Map<String,String> map, String idArray, String sensorType)
    {
        // TODO 【波长对齐修复】如果是FBG，对Map传感器排序进行修复-算法太花时间，暂时关闭，在存数据时修复
//        if(sensorType.equals("ST"))
//        {
//            for (String e : map.keySet())
//            {
//                map.put(e, waveFixSST(map.get(e)));
//            }
//        }
//        if(sensorType.equals("FT"))
//        {
//            for (String e : map.keySet())
//            {
//                map.put(e, waveFixSFT(map.get(e)));
//            }
//        }

//        for (String e : map.keySet())
//        {
//            System.out.println(map.get(e));
//            break;
//        }
        String[] idArr = idArray.split(",");
        String[] arr = idArr[0].split("-");
        int valueNum = map.size();
        // 输出数组
        String[][] outArray = new String[idArr.length][valueNum];
        if (!"CN".equals(sensorType))
        {
            //String sensorType =arr[1].substring(1,3).trim();// 传感器类型
            String channel = "0";
            String point = arr[2];
            int channelInt = Integer.parseInt(channel);
            int pointInt;
            // 循坏分别给每个id获取对应的值
            for(int i=0; i<idArr.length; i++)
            {
                arr = idArr[i].split("-");
                if(arr[1].length() > 3 )
                {
                    channel = arr[1].substring(3,5).trim();
                    channelInt = Integer.parseInt(channel);
                }
                point = arr[2];
                pointInt = Integer.parseInt(point);
                int j=0;
                for(String akey : map.keySet())
                {
                    String mapValue = map.get(akey);
                    // 对于DS18b20“,,,,,”情况处理，切片占位
                    String[] valueArr = mapValue.split(",",-1);
                    String value = "0";
                    // 针对各类数据, 读取对应传感器值
                    if("DT".equals(sensorType))
                    {
                        value = valueArr[channelInt*8 + pointInt];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("ET".equals(sensorType))
                    {
                        value = valueArr[channelInt*2 + pointInt];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("FT".equals(sensorType) || "ST".equals(sensorType))
                    {
                        value = valueArr[channelInt*20 + pointInt];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("CD".equals(sensorType))
                    {
                        value = valueArr[pointInt];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    outArray[i][j] = value;
                    j++;
                    //System.out.println(i+"value: "+ value);
                }
            }
        }

        if ("CN".equals(sensorType))
        {
            // 循坏分别给每个id获取对应的值
            for(int i=0; i<idArr.length; i++)
            {
                String[] arr2 = idArr[i].split("-");
                String dataname = arr2[1];
                int j=0;
                for(String akey : map.keySet())
                {
                    String[] valueArr = map.get(akey).split(",");
                    String value = "0";
                    if("CH".equals(dataname)) {
                        value = valueArr[0];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("XPOS".equals(dataname)) {
                        value = valueArr[1];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("YPOS".equals(dataname)) {
                        value = valueArr[2];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("ZPOS".equals(dataname)) {
                        value = valueArr[3];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("MAPOS".equals(dataname)) {
                        value = valueArr[4];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("FR".equals(dataname)) {
                        value = valueArr[5];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("SP".equals(dataname)) {
                        value = valueArr[6];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("XPWR".equals(dataname)) {
                        value = valueArr[7];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("YPWR".equals(dataname)) {
                        value = valueArr[8];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("ZPWR".equals(dataname)) {
                        value = valueArr[9];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("MAPWR".equals(dataname)) {
                        value = valueArr[10];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("XFU".equals(dataname)) {
                        value = valueArr[11];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("YFU".equals(dataname)) {
                        value = valueArr[12];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("ZFU".equals(dataname)) {
                        value = valueArr[13];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("MAFU".equals(dataname)) {
                        value = valueArr[14];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    if("PA".equals(dataname)) {
                        value = valueArr[15];
                        if ("".equals(value)){
                            value = "0";
                        }
                    }
                    outArray[i][j] = value;
                    j++;
                    //System.out.println(i+"value: "+ value);
                }
            }
        }

        return outArray;
    }

    /**
     * 传感器编号索引 -适合武重机床传感器
     * @param sensorType 传感器类型
     * @return 返回传感器编号抬头信息数组
     */
    public static String[] sensorIndex(String sensorType)
    {
        String allSDT = "001-SDT00-00,001-SDT00-01,001-SDT00-02,001-SDT00-03,001-SDT00-04,001-SDT00-05,001-SDT00-06,001-SDT00-07,001-SDT01-00,001-SDT01-01,001-SDT01-02,001-SDT01-03,001-SDT01-04,001-SDT01-05,001-SDT01-06,001-SDT01-07,001-SDT02-00,001-SDT02-01,001-SDT02-02,001-SDT02-03,001-SDT02-04,001-SDT02-05,001-SDT02-06,001-SDT02-07,001-SDT03-00,001-SDT03-01,001-SDT03-02,001-SDT03-03,001-SDT03-04,001-SDT03-05,001-SDT03-06,001-SDT03-07,001-SDT04-00,001-SDT04-01,001-SDT04-02,001-SDT04-03,001-SDT04-04,001-SDT04-05,001-SDT04-06,001-SDT04-07,001-SDT05-00,001-SDT05-01,001-SDT05-02,001-SDT05-03,001-SDT05-04,001-SDT05-05,001-SDT05-06,001-SDT05-07,001-SDT06-00,001-SDT06-01,001-SDT06-02,001-SDT06-03,001-SDT06-04,001-SDT06-05,001-SDT06-06,001-SDT06-07,001-SDT07-00,001-SDT07-01,001-SDT07-02,001-SDT07-03,001-SDT07-04,001-SDT07-05,001-SDT07-06,001-SDT07-07";
        String allSFT = "001-SFT00-00,001-SFT00-01,001-SFT00-02,001-SFT00-03,001-SFT00-04,001-SFT00-05,001-SFT00-06,001-SFT00-07,001-SFT00-08,001-SFT00-09,001-SFT00-10,001-SFT00-11,001-SFT00-12,001-SFT00-13,001-SFT00-14,001-SFT00-15,001-SFT00-16,001-SFT00-17,001-SFT00-18,001-SFT00-19,001-SFT01-00,001-SFT01-01,001-SFT01-02,001-SFT01-03,001-SFT01-04,001-SFT01-05,001-SFT01-06,001-SFT01-07,001-SFT01-08,001-SFT01-09,001-SFT01-10,001-SFT01-11,001-SFT01-12,001-SFT01-13,001-SFT01-14,001-SFT01-15,001-SFT01-16,001-SFT01-17,001-SFT01-18,001-SFT01-19,001-SFT02-00,001-SFT02-01,001-SFT02-02,001-SFT02-03,001-SFT02-04,001-SFT02-05,001-SFT02-06,001-SFT02-07,001-SFT02-08,001-SFT02-09,001-SFT02-10,001-SFT02-11,001-SFT02-12,001-SFT02-13,001-SFT02-14,001-SFT02-15,001-SFT02-16,001-SFT02-17,001-SFT02-18,001-SFT02-19,001-SFT03-00,001-SFT03-01,001-SFT03-02,001-SFT03-03,001-SFT03-04,001-SFT03-05,001-SFT03-06,001-SFT03-07,001-SFT03-08,001-SFT03-09,001-SFT03-10,001-SFT03-11,001-SFT03-12,001-SFT03-13,001-SFT03-14,001-SFT03-15,001-SFT03-16,001-SFT03-17,001-SFT03-18,001-SFT03-19,001-SFT04-00,001-SFT04-01,001-SFT04-02,001-SFT04-03,001-SFT04-04,001-SFT04-05,001-SFT04-06,001-SFT04-07,001-SFT04-08,001-SFT04-09,001-SFT04-10,001-SFT04-11,001-SFT04-12,001-SFT04-13,001-SFT04-14,001-SFT04-15,001-SFT04-16,001-SFT04-17,001-SFT04-18,001-SFT04-19,001-SFT05-00,001-SFT05-01,001-SFT05-02,001-SFT05-03,001-SFT05-04,001-SFT05-05,001-SFT05-06,001-SFT05-07,001-SFT05-08,001-SFT05-09,001-SFT05-10,001-SFT05-11,001-SFT05-12,001-SFT05-13,001-SFT05-14,001-SFT05-15,001-SFT05-16,001-SFT05-17,001-SFT05-18,001-SFT05-19,001-SFT06-00,001-SFT06-01,001-SFT06-02,001-SFT06-03,001-SFT06-04,001-SFT06-05,001-SFT06-06,001-SFT06-07,001-SFT06-08,001-SFT06-09,001-SFT06-10,001-SFT06-11,001-SFT06-12,001-SFT06-13,001-SFT06-14,001-SFT06-15,001-SFT06-16,001-SFT06-17,001-SFT06-18,001-SFT06-19,001-SFT07-00,001-SFT07-01,001-SFT07-02,001-SFT07-03,001-SFT07-04,001-SFT07-05,001-SFT07-06,001-SFT07-07,001-SFT07-08,001-SFT07-09,001-SFT07-10,001-SFT07-11,001-SFT07-12,001-SFT07-13,001-SFT07-14,001-SFT07-15,001-SFT07-16,001-SFT07-17,001-SFT07-18,001-SFT07-19,001-SFT08-00,001-SFT08-01,001-SFT08-02,001-SFT08-03,001-SFT08-04,001-SFT08-05,001-SFT08-06,001-SFT08-07,001-SFT08-08,001-SFT08-09,001-SFT08-10,001-SFT08-11,001-SFT08-12,001-SFT08-13,001-SFT08-14,001-SFT08-15,001-SFT08-16,001-SFT08-17,001-SFT08-18,001-SFT08-19,001-SFT09-00,001-SFT09-01,001-SFT09-02,001-SFT09-03,001-SFT09-04,001-SFT09-05,001-SFT09-06,001-SFT09-07,001-SFT09-08,001-SFT09-09,001-SFT09-10,001-SFT09-11,001-SFT09-12,001-SFT09-13,001-SFT09-14,001-SFT09-15,001-SFT09-16,001-SFT09-17,001-SFT09-18,001-SFT09-19,001-SFT10-00,001-SFT10-01,001-SFT10-02,001-SFT10-03,001-SFT10-04,001-SFT10-05,001-SFT10-06,001-SFT10-07,001-SFT10-08,001-SFT10-09,001-SFT10-10,001-SFT10-11,001-SFT10-12,001-SFT10-13,001-SFT10-14,001-SFT10-15,001-SFT10-16,001-SFT10-17,001-SFT10-18,001-SFT10-19,001-SFT11-00,001-SFT11-01,001-SFT11-02,001-SFT11-03,001-SFT11-04,001-SFT11-05,001-SFT11-06,001-SFT11-07,001-SFT11-08,001-SFT11-09,001-SFT11-10,001-SFT11-11,001-SFT11-12,001-SFT11-13,001-SFT11-14,001-SFT11-15,001-SFT11-16,001-SFT11-17,001-SFT11-18,001-SFT11-19,001-SFT12-00,001-SFT12-01,001-SFT12-02,001-SFT12-03,001-SFT12-04,001-SFT12-05,001-SFT12-06,001-SFT12-07,001-SFT12-08,001-SFT12-09,001-SFT12-10,001-SFT12-11,001-SFT12-12,001-SFT12-13,001-SFT12-14,001-SFT12-15,001-SFT12-16,001-SFT12-17,001-SFT12-18,001-SFT12-19,001-SFT13-00,001-SFT13-01,001-SFT13-02,001-SFT13-03,001-SFT13-04,001-SFT13-05,001-SFT13-06,001-SFT13-07,001-SFT13-08,001-SFT13-09,001-SFT13-10,001-SFT13-11,001-SFT13-12,001-SFT13-13,001-SFT13-14,001-SFT13-15,001-SFT13-16,001-SFT13-17,001-SFT13-18,001-SFT13-19,001-SFT14-00,001-SFT14-01,001-SFT14-02,001-SFT14-03,001-SFT14-04,001-SFT14-05,001-SFT14-06,001-SFT14-07,001-SFT14-08,001-SFT14-09,001-SFT14-10,001-SFT14-11,001-SFT14-12,001-SFT14-13,001-SFT14-14,001-SFT14-15,001-SFT14-16,001-SFT14-17,001-SFT14-18,001-SFT14-19,001-SFT15-00,001-SFT15-01,001-SFT15-02,001-SFT15-03,001-SFT15-04,001-SFT15-05,001-SFT15-06,001-SFT15-07,001-SFT15-08,001-SFT15-09,001-SFT15-10,001-SFT15-11,001-SFT15-12,001-SFT15-13,001-SFT15-14,001-SFT15-15,001-SFT15-16,001-SFT15-17,001-SFT15-18,001-SFT15-19,001-SFT16-00,001-SFT16-01,001-SFT16-02,001-SFT16-03,001-SFT16-04,001-SFT16-05,001-SFT16-06,001-SFT16-07,001-SFT16-08,001-SFT16-09,001-SFT16-10,001-SFT16-11,001-SFT16-12,001-SFT16-13,001-SFT16-14,001-SFT16-15,001-SFT16-16,001-SFT16-17,001-SFT16-18,001-SFT16-19,001-SFT17-00,001-SFT17-01,001-SFT17-02,001-SFT17-03,001-SFT17-04,001-SFT17-05,001-SFT17-06,001-SFT17-07,001-SFT17-08,001-SFT17-09,001-SFT17-10,001-SFT17-11,001-SFT17-12,001-SFT17-13,001-SFT17-14,001-SFT17-15,001-SFT17-16,001-SFT17-17,001-SFT17-18,001-SFT17-19,001-SFT18-00,001-SFT18-01,001-SFT18-02,001-SFT18-03,001-SFT18-04,001-SFT18-05,001-SFT18-06,001-SFT18-07,001-SFT18-08,001-SFT18-09,001-SFT18-10,001-SFT18-11,001-SFT18-12,001-SFT18-13,001-SFT18-14,001-SFT18-15,001-SFT18-16,001-SFT18-17,001-SFT18-18,001-SFT18-19,001-SFT19-00,001-SFT19-01,001-SFT19-02,001-SFT19-03,001-SFT19-04,001-SFT19-05,001-SFT19-06,001-SFT19-07,001-SFT19-08,001-SFT19-09,001-SFT19-10,001-SFT19-11,001-SFT19-12,001-SFT19-13,001-SFT19-14,001-SFT19-15,001-SFT19-16,001-SFT19-17,001-SFT19-18,001-SFT19-19,001-SFT20-00,001-SFT20-01,001-SFT20-02,001-SFT20-03,001-SFT20-04,001-SFT20-05,001-SFT20-06,001-SFT20-07,001-SFT20-08,001-SFT20-09,001-SFT20-10,001-SFT20-11,001-SFT20-12,001-SFT20-13,001-SFT20-14,001-SFT20-15,001-SFT20-16,001-SFT20-17,001-SFT20-18,001-SFT20-19,001-SFT21-00,001-SFT21-01,001-SFT21-02,001-SFT21-03,001-SFT21-04,001-SFT21-05,001-SFT21-06,001-SFT21-07,001-SFT21-08,001-SFT21-09,001-SFT21-10,001-SFT21-11,001-SFT21-12,001-SFT21-13,001-SFT21-14,001-SFT21-15,001-SFT21-16,001-SFT21-17,001-SFT21-18,001-SFT21-19,001-SFT22-00,001-SFT22-01,001-SFT22-02,001-SFT22-03,001-SFT22-04,001-SFT22-05,001-SFT22-06,001-SFT22-07,001-SFT22-08,001-SFT22-09,001-SFT22-10,001-SFT22-11,001-SFT22-12,001-SFT22-13,001-SFT22-14,001-SFT22-15,001-SFT22-16,001-SFT22-17,001-SFT22-18,001-SFT22-19,001-SFT23-00,001-SFT23-01,001-SFT23-02,001-SFT23-03,001-SFT23-04,001-SFT23-05,001-SFT23-06,001-SFT23-07,001-SFT23-08,001-SFT23-09,001-SFT23-10,001-SFT23-11,001-SFT23-12,001-SFT23-13,001-SFT23-14,001-SFT23-15,001-SFT23-16,001-SFT23-17,001-SFT23-18,001-SFT23-19,001-SFT24-00,001-SFT24-01,001-SFT24-02,001-SFT24-03,001-SFT24-04,001-SFT24-05,001-SFT24-06,001-SFT24-07,001-SFT24-08,001-SFT24-09,001-SFT24-10,001-SFT24-11,001-SFT24-12,001-SFT24-13,001-SFT24-14,001-SFT24-15,001-SFT24-16,001-SFT24-17,001-SFT24-18,001-SFT24-19";
        String allSST = "001-SST00-00,001-SST00-01,001-SST00-02,001-SST00-03,001-SST00-04,001-SST00-05,001-SST00-06,001-SST00-07,001-SST00-08,001-SST00-09,001-SST00-10,001-SST00-11,001-SST00-12,001-SST00-13,001-SST00-14,001-SST00-15,001-SST00-16,001-SST00-17,001-SST00-18,001-SST00-19,001-SST01-00,001-SST01-01,001-SST01-02,001-SST01-03,001-SST01-04,001-SST01-05,001-SST01-06,001-SST01-07,001-SST01-08,001-SST01-09,001-SST01-10,001-SST01-11,001-SST01-12,001-SST01-13,001-SST01-14,001-SST01-15,001-SST01-16,001-SST01-17,001-SST01-18,001-SST01-19,001-SST02-00,001-SST02-01,001-SST02-02,001-SST02-03,001-SST02-04,001-SST02-05,001-SST02-06,001-SST02-07,001-SST02-08,001-SST02-09,001-SST02-10,001-SST02-11,001-SST02-12,001-SST02-13,001-SST02-14,001-SST02-15,001-SST02-16,001-SST02-17,001-SST02-18,001-SST02-19,001-SST03-00,001-SST03-01,001-SST03-02,001-SST03-03,001-SST03-04,001-SST03-05,001-SST03-06,001-SST03-07,001-SST03-08,001-SST03-09,001-SST03-10,001-SST03-11,001-SST03-12,001-SST03-13,001-SST03-14,001-SST03-15,001-SST03-16,001-SST03-17,001-SST03-18,001-SST03-19,001-SST04-00,001-SST04-01,001-SST04-02,001-SST04-03,001-SST04-04,001-SST04-05,001-SST04-06,001-SST04-07,001-SST04-08,001-SST04-09,001-SST04-10,001-SST04-11,001-SST04-12,001-SST04-13,001-SST04-14,001-SST04-15,001-SST04-16,001-SST04-17,001-SST04-18,001-SST04-19,001-SST05-00,001-SST05-01,001-SST05-02,001-SST05-03,001-SST05-04,001-SST05-05,001-SST05-06,001-SST05-07,001-SST05-08,001-SST05-09,001-SST05-10,001-SST05-11,001-SST05-12,001-SST05-13,001-SST05-14,001-SST05-15,001-SST05-16,001-SST05-17,001-SST05-18,001-SST05-19,001-SST06-00,001-SST06-01,001-SST06-02,001-SST06-03,001-SST06-04,001-SST06-05,001-SST06-06,001-SST06-07,001-SST06-08,001-SST06-09,001-SST06-10,001-SST06-11,001-SST06-12,001-SST06-13,001-SST06-14,001-SST06-15,001-SST06-16,001-SST06-17,001-SST06-18,001-SST06-19";
        String allSCD = "001-SCD-01,001-SCD-02,001-SCD-03";

        if("SDT".equals(sensorType))
        {
            return allSDT.split(",");
        }
        if("SFT".equals(sensorType))
        {
            return allSFT.split(",");
        }
        if("SST".equals(sensorType))
        {
            return allSST.split(",");
        }
        if("SCD".equals(sensorType))
        {
            return allSCD.split(",");
        }
        return null;
    }

    /**
     * 存Hbase的Map中如果同一传感器数据有多个时间，保留最新的那一条
     * 例如有01ET171101164748、01ET171101164750则保留01ET171101164750
     *
     * @param hbaseSaveMap 存Hbase的Map
     * @return 滤除后的Map
     */
    public static Map<String, String> hbaseSaveMapFilter(Map<String, String> hbaseSaveMap)
    {
        Map<String, String> hbaseSaveMapFilted  = new HashMap<>();
        // 01ET  171101164748
        Map<String, String> key4value12Map = new HashMap<>();
        for (String key : hbaseSaveMap.keySet()) {
            if (key.length() > 15) {
                key4value12Map.put(key.substring(0,4), key.substring(4,16));
            }
        }
        for (String key : key4value12Map.keySet()) {
            String fullKey = key + key4value12Map.get(key);
            String value = hbaseSaveMap.get(fullKey);
            // 滤除异常值
            value = value.replace("-nan","0");
            value = value.replace("inf","0");
            hbaseSaveMapFilted.put(fullKey, value);
        }
        return hbaseSaveMapFilted;
    }

    public static String sensorZeroValue(String seneor){
        switch (seneor){
            case "CD":
                return "0,0,0,";
            case "DT":
                return "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,";
            case "ET":
                return "0,0,0,0,";
            case "ST":
                return "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,";
            case "FT":
                return "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,";
            case "CN":
                return "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,";
            default:
                return "";
        }
    }

    /**
     * idArray修正 - SFT拆分为SST和SFT 为了兼容大哥数据导出
     *
     * @param idArray 输入idArray
     * @return 修正的idArray
     */
    public static String[] fixSFTToSSTAndSFT(String[] idArray){
        List<String> fixIdList = new ArrayList<>();
        for (int i = 0; i < idArray.length; i++) {
            if (idArray[i].length() > 7 && "SFT".equals(idArray[i].substring(4,7))) {
//                System.out.println(idArray[i]);
                String[] temp = idArray[i].split(",");
                // FBG大id转SFT、SST
                for (int j = 0; j < temp.length; j++) {
                    String fixFBGid = FGBtoSSTSFTMap.get(temp[j]);
                    temp[j] = fixFBGid;
                }
                List<String> sstList = new ArrayList<>();
                List<String> sftList = new ArrayList<>();
                boolean startSST = true;
                for (int j = 0; j < temp.length; j++) {
                    // 判断SST先还是SFT先
                    if (j==0 && "ST".equals(temp[j].substring(5, 7))){
                        startSST =  true;
                    }
                    if (j==0 && !"ST".equals(temp[j].substring(5, 7))){
                        startSST =  false;
                    }
                    if ("ST".equals(temp[j].substring(5, 7))){
                        sstList.add(temp[j]);
                    } else {
                        sftList.add(temp[j]);
                    }
                }

                if (startSST){
                    if (sstList.size()>0){
                        String lineSST = StringUtils.join(sstList,",");
                        fixIdList.add(lineSST);
                    }
                    if (sftList.size()>0){
                        String lineSFT = StringUtils.join(sftList,",");
                        fixIdList.add(lineSFT);
                    }
                } else {
                    if (sftList.size()>0){
                        String lineSFT = StringUtils.join(sftList,",");
                        fixIdList.add(lineSFT);
                    }
                    if (sstList.size()>0){
                        String lineSST = StringUtils.join(sstList,",");
                        fixIdList.add(lineSST);
                    }
                }

            } else {
                fixIdList.add(idArray[i]);
            }
        }
        String[] idArrayFix = new String[fixIdList.size()];
        fixIdList.toArray(idArrayFix);
//        for (String a : fixIdList) {
//            System.out.println(a);
//        }
        return idArrayFix;
    }



}
